//
//  AppLogHelper.swift
//  GreenDeal
//
//  Created by Moennig Q on 2023/11/6.
//

import Foundation
class AppLogHelper: NSObject{
    let semphore = DispatchSemaphore(value: 0)
    static let shared = AppLogHelper()
    //MARK: - 顺序上传日志
    func sendErrorLog(_ errorMsg: String, errorType: ErrorType){
        GlobalOperationQueue.addOperation {
            let viewModel = SystemViewModel()
            viewModel.setBlockAfterNetwork({ (result , _) -> Void in
                DispatchQueue.main.async {
                    debugPrint("日志上传成功")
                }
                self.semphore.signal()
            }) { (code, error) -> Void in
                DispatchQueue.main.async {
                    debugPrint("日志上传失败")
                }
                self.semphore.signal()
            }
            viewModel.sendErrorLog(errorMsg, type: errorType)
            self.semphore.wait()
        }
    }
    
}
